﻿@using LogDashboard.Extensions
@inherits RazorLight.TemplatePage<IEnumerable<LogDashboard.Models.ILogModel>>
@{
    Layout = null;
}
<div class="table-responsive">
    <table class="table row mx-0 table-hover table-expandable">
        <thead class="w-100">
            <tr class="row mx-0">
                <th class="col-1">Id</th>
                <th class="col-3">Logger</th>
                <th class="col-1">级别</th>
                <th class="col-4">消息</th>
                <th class="col-2">时间</th>
            </tr>
        </thead>
        <tbody class="w-100">
            @foreach (var item in Model)
            {
                <tr class="row mx-0">
                    <td class="col-1"><a href="javascript:void(0);" onclick="logInfo('@item.Id')">@item.Id</a></td>
                    <td class="col-3"><span>@item.Logger</span></td>
                    @{
                        if (item.Level.ToLower() == "error")
                        {
                            <div class="modal fade" id="@item.Id">
                                <div class="modal-dialog modal-lg" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header bg-danger border-0"><h5 class="modal-title text-white">Exception</h5><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div><div class="modal-body">
                                            <pre>@item.Exception</pre>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <td class="col-1"><button class="btn btn-outline-@item.Level.ToUpper()" onclick='$("#@item.Id").modal();'>@item.Level</button></td>
                        }
                        else
                        {
                            <td class="col-1"><button class="btn btn-outline-@item.Level.ToUpper()">@item.Level</button></td>
                        }
                    }
                    <td class="col-4">
                        @{
                            var message = item.Message;
                            if (message.Length > 90)
                            {
                                message = message.Substring(0, 90) + "........";
                            }
                        }
                        @message
                    </td>
                    <td class="col-2">@item.LongDate</td>
                </tr>
                <tr class="row mx-0">
                    <td colspan="10" style="width: 100%">
                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <tbody>
                                    <tr>
                                        <td>Id</td>
                                        <td class="text-nowrap">@item.Id</td>
                                    </tr>
                                    <tr>
                                        <td>时间</td>
                                        <td class="text-nowrap">@item.LongDate</td>
                                    </tr>
                                    <tr>
                                        <td>级别</td>
                                        <td class="text-nowrap"><button class="btn btn-outline-@item.Level">@item.Level</button></td>
                                    </tr>
                                    <tr>
                                        <td>Logger</td>
                                        <td class="text-nowrap">@item.Logger</td>
                                    </tr>
                                    <tr>
                                        <td>消息</td>
                                        <td class="text-nowrap">@item.Message</td>
                                    </tr>

                                </tbody>
                            </table>
                            <div class="card">
                                <div class="card-header bg-light">
                                    堆栈信息
                                </div>
                                <div class="card-body">
                                    <pre>@item.Exception</pre>
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>